import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingOrderMasterApi {
  /** 预约订单主信息 */
  export interface BookingOrderMaster {
    id: number; // 预约订单ID
    orderCode?: string; // 预约订单编码
    orderType?: string; // 订单类型
    customerId?: number; // 客户ID
    customerName?: string; // 客户姓名
    customerPhone: string; // 客户电话
    customerGender: string; // 性别
    customerAge: number; // 年龄
    groupId: number; // 团体ID
    groupSequence: number; // 团体中的序号
    groupLeaderId: number; // 团体负责人ID
    bookingDate?: string | Dayjs; // 预约日期
    expectedArrivalTime: string | Dayjs; // 预计到店时间
    lateArrivalTolerance: number; // 迟到容忍时间(分钟)
    bookingStatus?: string; // 预约状态
    payStatus?: string; // 支付状态
    priorityLevel: string; // 优先级
    convertedConsumptionOrderId: number; // 转换后的消费订单ID
    conversionTime: string | Dayjs; // 转换时间
    conversionUserId: number; // 转换操作人ID
    orderSource?: string; // 订单来源
    sourceChannel: string; // 来源渠道
    referralCode: string; // 推荐码
    specialRequirements: string; // 特殊需求
    healthNotes: string; // 健康备注
    orderNotes: string; // 订单备注
    estimatedTotalAmount: number; // 预估总金额
    estimatedDiscountAmount: number; // 预估折扣金额
    estimatedFinalAmount: number; // 预估最终金额
    depositAmount: number; // 押金金额
    depositStatus: string; // 押金状态
    reminderSent: boolean; // 是否已发送提醒
    storeId?: number; // 门店ID
    orgId?: number; // 组织ID
  }
}

/** 查询预约订单主分页 */
export function getBookingOrderMasterPage(params: PageParam) {
  return requestClient.get<PageResult<BookingOrderMasterApi.BookingOrderMaster>>('/spa/booking-order-master/page', { params });
}

/** 查询预约订单主详情 */
export function getBookingOrderMaster(id: number) {
  return requestClient.get<BookingOrderMasterApi.BookingOrderMaster>(`/spa/booking-order-master/get?id=${id}`);
}

/** 新增预约订单主 */
export function createBookingOrderMaster(data: BookingOrderMasterApi.BookingOrderMaster) {
  return requestClient.post('/spa/booking-order-master/create', data);
}

/** 修改预约订单主 */
export function updateBookingOrderMaster(data: BookingOrderMasterApi.BookingOrderMaster) {
  return requestClient.put('/spa/booking-order-master/update', data);
}

/** 删除预约订单主 */
export function deleteBookingOrderMaster(id: number) {
  return requestClient.delete(`/spa/booking-order-master/delete?id=${id}`);
}


/** 导出预约订单主 */
export function exportBookingOrderMaster(params: any) {
  return requestClient.download('/spa/booking-order-master/export-excel', { params });
}

